package com.client.rpc;

import com.entity.RpcInterface;
import com.rpc.annotation.RpcClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class RpcController {
    @RpcClient(group = "resultService",version = "1.0")
    private RpcInterface rpcInterface;
    @RpcClient(group = "resultService",version = "2.0",server = "admin2")
    private RpcInterface rpcInterface2;

    @GetMapping("rpcService")
    public Object rpcService() {
        String ceshi = rpcInterface.queryData("ceshi");
        return ceshi ;
    }

    @PostMapping("saveData")
    public Object saveData(@RequestBody Map<String,Object> params){
        System.out.println(params);
        return "传递成功";
    }

    @GetMapping("rpcService2")
    public Object rpcService2() {
        String ceshi = rpcInterface2.queryData("asdf");
        return ceshi ;
    }


}
